﻿using System;
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media.Imaging;
using Avalonia.Platform;

namespace iOSClub.Toolkit.WindowApp.Converters;

public class BitmapConverter : IValueConverter
{
    public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        if (value is string s)
            return new Bitmap(AssetLoader.Open(new Uri($"avares://iOSClub.Toolkit.WindowApp/Assets/{s}.png"))); 
        return value;
    }

    public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
    {
        return value;
    }
}